package com.ruoyi.tester.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tester.mapper.TesterInterfaceMapper;
import com.ruoyi.tester.domain.TesterInterface;
import com.ruoyi.tester.service.ITesterInterfaceService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.util.CollectionUtils;

/**
 * 接口信息Service业务层处理
 * 
 * @author SJ
 * @date 2022-04-22
 */
@Service
public class TesterInterfaceServiceImpl implements ITesterInterfaceService 
{
    @Autowired
    private TesterInterfaceMapper testerInterfaceMapper;

    /**
     * 查询接口信息
     * 
     * @param interfaceId 接口信息主键
     * @return 接口信息
     */
    @Override
    public TesterInterface selectTesterInterfaceByInterfaceId(Long interfaceId)
    {
        return testerInterfaceMapper.selectTesterInterfaceByInterfaceId(interfaceId);
    }

    /**
     * 查询接口信息列表
     * 
     * @param testerInterface 接口信息
     * @return 接口信息
     */
    @Override
    public List<TesterInterface> selectTesterInterfaceList(TesterInterface testerInterface)
    {
        return testerInterfaceMapper.selectTesterInterfaceList(testerInterface);
    }

    /**
     * 新增接口信息
     * 
     * @param testerInterface 接口信息
     * @return 结果
     */
    @Override
    public int insertTesterInterface(TesterInterface testerInterface)
    {
        testerInterface.setCreateTime(DateUtils.getNowDate());
        return testerInterfaceMapper.insertTesterInterface(testerInterface);
    }

    @Override
    public int batchInsertTesterInterface(List<TesterInterface> list){
        if(CollectionUtils.isEmpty(list)){
            return 0;
        }
        list.stream().forEach(x -> {
            x.setCreateTime(DateUtils.getNowDate());
            x.setStatus("0");
        });
        return testerInterfaceMapper.batchInsertTesterInterface(list);
    }

    /**
     * 修改接口信息
     * 
     * @param testerInterface 接口信息
     * @return 结果
     */
    @Override
    public int updateTesterInterface(TesterInterface testerInterface)
    {
        testerInterface.setUpdateTime(DateUtils.getNowDate());
        return testerInterfaceMapper.updateTesterInterface(testerInterface);
    }

    /**
     * 批量删除接口信息
     * 
     * @param interfaceIds 需要删除的接口信息主键
     * @return 结果
     */
    @Override
    public int deleteTesterInterfaceByInterfaceIds(String interfaceIds)
    {
        return testerInterfaceMapper.deleteTesterInterfaceByInterfaceIds(Convert.toStrArray(interfaceIds));
    }

    /**
     * 删除接口信息信息
     * 
     * @param interfaceId 接口信息主键
     * @return 结果
     */
    @Override
    public int deleteTesterInterfaceByInterfaceId(Long interfaceId)
    {
        return testerInterfaceMapper.deleteTesterInterfaceByInterfaceId(interfaceId);
    }
}
